#include <stdio.h>
#include "html_utils.h"

void http_error(char * msg)
{
  header("text/html");
  html_header();
  printf("<h1>Error</h1><p> %s", msg);
  html_tailer();
  exit(0);
}

void html_header()
{
  char * html_header_text = "<html><head>"
"<style>"
"h1, h2, table, input, p {margin-left: 10px;}"
"div.main {margin: auto; width: 600px; border: solid 1px green}"
"td {  background-color: #e2e2e2;}"
"</style>"
"</head><body><div class=\"main\">";
  printf(html_header_text);
}

void html_tailer()
{
  char * html_tailer_text = "</div></body></html>";
  printf(html_tailer_text);
}


void table_with_4_columns_header(char * column_2_title, char * column_3_title) 
{
  printf("<table><tr><td> </td><td>%s</td><td>%s</td><td> </td></tr>", column_2_title, column_3_title);
}

void table_with_4_columns_row(char * col1, char * col2, char * col3, char * col4)
{
  printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td>", col1, col2, col3, col4);
}

void table_tailer() 
{
  printf("</table>");
}


void header(char * type) 
{
  printf("Content-Type: %s\n\n", type);
}





